//-----------------------------------------------------------------------
// <copyright file="BulkOrderTerritoryService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class BulkOrderTerritoryService
    {

		public static BulkOrderTerritoryCollection GetBulkOrderTerritoriesByBulkOrder(int bulkOrderID)
		{            
			try
			{
				BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
				return bulkOrderTerritoryDAO.GetBulkOrderTerritoriesByBulkOrder(bulkOrderID);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetBulkOrderTerritoriesException, ex);
			}
		}        


		public static HDTerritoriesPrices GetHDTerritoriesPricesByProductCodeAndTerritoryID(string productCode, int territoryID)
		{            
			try
			{
				BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
				return bulkOrderTerritoryDAO.GetHDTerritoriesPricesByProductCodeAndTerritoryID(productCode,territoryID);                
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetBulkOrderTerritoryException, ex);
			}
		}            

        #region BulkOrderTerritory

        public static void CreateBulkOrderTerritory(BulkOrderTerritory bulkOrderTerritory)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                bulkOrderTerritoryDAO.CreateBulkOrderTerritory(bulkOrderTerritory);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateBulkOrderTerritoryException, ex);
            }
        }        

        public static void UpdateBulkOrderTerritory(BulkOrderTerritory bulkOrderTerritory)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                bulkOrderTerritoryDAO.UpdateBulkOrderTerritory(bulkOrderTerritory);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateBulkOrderTerritoryException, ex);
            }
        }        

        public static void DeleteBulkOrderTerritory(int bulkOrderID, int territoryID)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                bulkOrderTerritoryDAO.DeleteBulkOrderTerritory(bulkOrderID, territoryID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteBulkOrderTerritoryException, ex);
            }
        }
        
        public static BulkOrderTerritory GetBulkOrderTerritory(int bulkOrderID, int territoryID)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                return bulkOrderTerritoryDAO.GetBulkOrderTerritory(bulkOrderID, territoryID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBulkOrderTerritoryException, ex);
            }
        }                
		
        public static BulkOrderTerritoryCollection GetBulkOrderTerritories(BulkOrderTerritoryColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                return bulkOrderTerritoryDAO.GetBulkOrderTerritories(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBulkOrderTerritoriesException, ex);
            }
        }        

        public static BulkOrderTerritoryCollection GetBulkOrderTerritories(BulkOrderTerritoryColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                BulkOrderTerritoryDAO bulkOrderTerritoryDAO = new BulkOrderTerritoryDAO();
                return bulkOrderTerritoryDAO.GetBulkOrderTerritories(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBulkOrderTerritoriesException, ex);
            }
        }        

        #endregion
    }
}